//
//  LZBaseView.swift
//  halikaPeso
//
//  Created by L-zh on 2024/12/18.
//

import UIKit

class LZBaseView: UIView {
    open weak var viewController: LZBaseVC?
    open weak var tableView: UITableView!
    
    init(frame: CGRect, viewController: LZBaseVC, tableView: UITableView!) {
        self.viewController = viewController
        self.tableView = tableView
        super.init(frame: frame)
        setupUI()
    }
    
    init(frame: CGRect, viewController: LZBaseVC) {
        self.viewController = viewController
        self.tableView = nil
        super.init(frame: frame)
        setupUI()
    }
    
    required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    open func setupUI() {}
    
    public func injectionIIIAction() {}
    
    
}

class LZBaseTableViewCell: UITableViewCell {
    override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
        super.init(style: style, reuseIdentifier: reuseIdentifier)
        setupUI()
    }

    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }

    open func setupUI() {
        selectionStyle = .none
    }
}

class LLBaseTableSectionHeaderView: UITableViewHeaderFooterView {
    override init(reuseIdentifier: String?) {
        super.init(reuseIdentifier: reuseIdentifier)
        setupUI()
    }

    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }

    open func setupUI() {
        contentView.backgroundColor = UIColor.white
    }

    override func layoutSubviews() {
        super.layoutSubviews()
        contentView.addSubview(lineView)
        lineView.snp.makeConstraints { make in
            make.left.right.bottom.equalTo(self.contentView)
            make.height.equalTo(APPScale(f: 1))
        }
    }

    public lazy var lineView: UIView = {
        let view = UIView()
        view.backgroundColor = UIColor.groupTableViewBackground
        return view
    }()
}

class LLBaseTableSectionFooterView: UITableViewHeaderFooterView {
    override init(reuseIdentifier: String?) {
        super.init(reuseIdentifier: reuseIdentifier)
        setupUI()
    }

    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }

    open func setupUI() {
        backgroundColor = UIColor.white
    }
}

class LLBaseCollectionCell: UICollectionViewCell {
    override init(frame: CGRect) {
        super.init(frame: frame)
        setupUI()
    }

    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }

    open func setupUI() {
        backgroundColor = UIColor.white
    }
}


